<html>
<head>
	<meta charset='utf-8' />
	<title>后台管理</title>
	<meta http-equiv="keywords" content="求职,招聘,房屋,出租,出售,求租,求购,宠物,二手,二手车,二手物品,旧货,寻物,寻人,出兑,外兑"> 
	<meta http-equiv="description" content="便民信息网,房屋租售,宠物交易,二手物品,二手车辆,寻物寻人,出兑信息">  
	<meta name="description" content="便民信息网,房屋租售,宠物交易,二手物品,二手车辆,寻物寻人,出兑信息"/>
	<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" />
	<style>
		@media screen and (max-width:450px){
			#nav_bottom{width:98%;margin:0 auto}
			#content{width:98%;margin:0 auto}
			/*页面宽度900以下时 .abc的宽度为450*/
		}
		@media screen and (min-width:450px){
			#nav_bottom{width:450px;margin:0 auto}
			#content{width:450px;margin:0 auto}
			/*页面宽度900以下时 .abc的宽度为450*/
		}
		.info_item{color:#444;margin:15px 0;display:flex}
		.info_item > div:last-child{flex:1}
	</style>
</head>
<body style='padding:0;margin:0;background:#eee'>
<!-- 1 Content容器 -->
<div id='Content'>



	<!-- 3 内容区-->
	<div style='margin:10px 0;word-break:break-all;padding:10px;'>

		<div style='float:right;text-align:right' onclick='After_Admin_Exit()'>退出</div>
		
		<h2 style='text-align:center;'>后台管理-用户发布记录</h2>
		
		<div id='user_id' style='text-align:center'></div>


		<div style='margin:10px auto'>
			<input type="text" id='after_info_search_text' style='width:120px'  placeholder='关键字' />
			<button type='button' id='after_info_search_btn'>搜索</button>
		</div>

		<div style='margin:10px auto'>
			信息状态选择：
			<select id='info_stat'>
				<option value="all">全部</option>
				<option value="0">待审核</option>
				<option value="1">正常</option>
				<option value="2">已删除</option>
				<option value="3">已封禁</option>
				<option value="4">关键词未通过</option>
			</select>

			<span id='Refresh_Infinite_Fpage_Data'></span>
		</div><hr>


		<!--列表区-->
		<div id='info_list'>

		</div><!--列表区-->

		<div style='margin:20px auto;text-align:center;' id='fpage'></div>


		<div style='margin:50px auto;text-align:center;'>
			<button onclick='Go_Back()'>返回</button>
		</div>

	</div>	<!-- 3 内容区结束-->	
</div><!-- 1 Content容器结束 -->




<!--查看指定图片-->
<div style='height;position:fixed;top:10px;width:100%'>
	<div style='width:400px;margin:0 auto'>
		<img id='load_img' src='http://tp-service.b0.upaiyun.com/bmxx8/c8e90a9a7e628bc07b6608f9db6110f9.jpg!db80' style='display:none;width:100%' />
	</div>
</div>


<!--底部导航容器-->
<div id='Nav_Bottom' style='position:fixed;bottom:0;width:100%;height:45px'>



</body>
</html>


<script src='./Public/jquery.js'></script>
<script src='./Public/fun.js'></script>
<script>
	Check_After_User_Cookie();	//检测登陆状态
	
	var priv_name = 'after_record_info';
	Priv_Check(priv_name,function(res){
		if(res != 'ok'){
			alert('没有权限!');
			//location.href = document.referrer;
			exit;
		}
	});



	//加载底部导航栏
	Load_NavBottom('after');



	//始初化当前页
	if(!sessionStorage.after_record_info_pnow){
		sessionStorage.after_record_info_pnow=1;
	}

	//缓存 信息状态选择
	if(!sessionStorage.after_record_info_infoStat){
		sessionStorage.after_record_info_infoStat = $('#info_stat').find("option:selected").val();
	}else{
		$('#info_stat').find('option').each(function(i,o){
			if($(o).val() == sessionStorage.after_record_info_infoStat){
				$(o).attr('selected',true);
			}
		});
	}

	$('#info_stat').change(function(){
		sessionStorage.after_record_info_infoStat = $(this).find("option:selected").val();
		sessionStorage.after_record_info_pnow = 1;
		Get_User_info();	//获取用户发布记录
	});




	function Go_Back(){
		switch(GetUrlParm('jump_type')){
			case '1':
				location.href="after_user.html";
			break;
			case '2':
				location.href="after_info.html";
			break;
		}
	}

	function Change_Info_Stat(info_id,info_stat,info_uid,con_type){

		var priv_name = 'AfterRecordInfo_Stat';
		Priv_Check(priv_name,function(res){
			if(res != 'ok'){
				alert('没有权限!');
				//location.href = document.referrer;
				exit;
			}
		});
		if(!confirm('确认该操作?')){
			return;
		}
		if(!con_type){
			con_type = 'none';
		}

		info_stat += 1;
		if(info_stat >= 4){
			info_stat = 0;
		}
		var type = 'After_Change_Info_Stat';
		Token(type,function(token){
			$.ajax({
				url:url,
				type:'post',
				data:{
					token:token,
					type:type,
					info_id:info_id,
					info_uid:info_uid,
					con_type:con_type,
					info_stat:info_stat
				},
				success(res){
					//alert(res);
					if(res == 'ok'){
						Get_User_info()
					}else{
						alert('操作失败!');
					}
				}
			});
		});
	}






	$(function(){

		Get_User_info();	//获取用户发布记录

		//刷新无限分页数据
		Refresh_Infinite_Fpage_Data(function(){
			sessionStorage.after_record_info_pnow = 1;
			Get_User_info();	//获取用户发布记录
		});

		//搜索事件
		$('#after_info_search_btn').click(function(){
			//alert(ChangeChar($('#after_info_search_text').val().trim()));
			Get_User_info();
		});

	});





	//获取用户发布记录
	function Get_User_info(){
		var uid = GetUrlParm('uid');
		if(!uid){
			return;
		}
		$('#user_id').text('当前用户id：'+uid);
		var type = 'After_Get_User_Issue_Info';
	//	alert(sessionStorage.after_record_info_infoStat);
		Token(type,function(token){
			$.ajax({
				url:url,
				type:'post',
				data:{
					type:type,
					token:token,
					uid:uid,
					pnow:sessionStorage.after_record_info_pnow,
					info_stat:sessionStorage.after_record_info_infoStat,
					search:ChangeChar($('#after_info_search_text').val().trim())
				},
				success(res){
					//alert(res);
					if(!/^{.*}$/.test(res)){
						alert('没有更多数据了!');
						$('#info_list').html('');
						if(sessionStorage.after_record_info_pnow > 1){
							sessionStorage.after_record_info_pnow = sessionStorage.after_record_info_pnow-1;
						}
						$('#fpage a:last-child').remove();
						return;
					}

					GetServiceList(function(res_service){
						var service_type = JSON.parse(res_service);

						$('#info_list').html('');
						//console.log(res);
						var info = JSON.parse(res);
						var data = info.data;
						var info_str = '';
						for(var i=0;i<data.length;i++){
							//判断信息状态
							var info_stat = " <div>信息id："+data[i].info_id;
							switch(data[i].info_stat){
								case 0:
								case '0':
									info_stat += "　　状态：<span style='color:#cc0'>待审核<span></div>";
									info_stat_but = '通过';
									break;
								case 1:
								case '1':
									info_stat += "　　状态：<span style='color:blue'>正常<span></div>";
									info_stat_but = '删除';
									break;
								case 2:
								case '2':
									info_stat += "　　状态：<span style='color:#aaa'>已删除<span></div>";
									info_stat_but = '封禁';
									break;
								case 3:
								case '3':
									info_stat += "　　状态：<span style='color:red'>已封禁<span></div>";
									info_stat_but = '解封';
									break;
								case 4:
								case '4':
									info_stat += "　　状态：<span style='color:red'>关键词未过<span></div>";
									info_stat_but = '';
									break;
							}
							//alert(data[i].info_stat);

							//解析时间
							var t = StampToYmd(parseInt(data[i].info_issue_time)*1000,1);

							if(data[i].info_auto_issue == 1){
								var auto_stat = '是';
							}else{
								var auto_stat = '否';
							}



							info_str += "<div style='border-bottom:1px solid #ccc;margin:5px auto'>";
							info_str += info_stat;
							info_str += "<div>标题："+data[i].info_title+"</div>";

							for(var s=0;s<service_type.length;s++){
								if(service_type[s][0] == data[i].info_service){
									var service_name = service_type[s][1];
								}else{
									continue;
								}
							}

							info_str += "<div>用户id："+data[i].info_uid+"　　　类型："+service_name+"</div>";
							info_str += "<div>内容："+data[i].info_content+"</div>";
							info_str += "<div>发布时间："+t+"　重发："+auto_stat+"</div>";
							info_str += "<div>联系人："+data[i].info_contacts+"　联系电话："+data[i].info_phone+"</div>";
							if(/^\["http/.test(data[i].info_imgs)){
								var img_str = '';
								var imgs = JSON.parse(data[i].info_imgs);
								for(var j=0;j<imgs.length;j++){
									img_str += "<img class='load_img' src='"+imgs[j]+"' height='50px' />　";
								}
								info_str += "<div>图片：</div>";
								info_str += "<div>　　　"+img_str+"</div>";
							}
							info_str += "<div style='text-align:right'>";
							//info_str += "<button onclick='Change_Info_Stat("+data[i].info_id+","+data[i].info_stat+","+data[i].info_uid+")'>"+info_stat_but+"</button>";
							if(data[i].info_stat == 4){
								info_str += "<button onclick=Change_Info_Stat("+data[i].info_id+","+data[i].info_stat+","+data[i].info_uid+",'allow')>通过</button>　<button onclick=Change_Info_Stat("+data[i].info_id+","+data[i].info_stat+","+data[i].info_uid+",'deny')>封禁</button>";
							}else{
								info_str += "<button onclick=Change_Info_Stat("+data[i].info_id+","+data[i].info_stat+","+data[i].info_uid+")>"+info_stat_but+"</button>";
							}
							info_str += "</div>";
							info_str += "</div>";
						}
						$('#info_list').html(info_str);

						//图片放大浏览
						$('.load_img').mouseover(function(){
							//alert(1);
							$('#load_img').show().attr('src',$(this).attr('src'));
						}).mouseout(function(){
							$('#load_img').hide();
						});
		
						Fpage4(info.pnow,info.max_page,function(pnow){
							sessionStorage.after_record_info_pnow = pnow;
							Get_User_info();
						},10,2);
					});	//获取服务分类列表 
				
				}

			});
		});
	}	






</script>

